﻿/**
 * Feature： 保存存在配置文件中数据的Model
 * Author: Shizhy
 * Date: 2016-01-18
 */

using System;

namespace DotNet.Configure
{
    [Serializable]
    public class ConfigValue
    {
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 数据类型,默认为System.String
        /// </summary>
        public Type DataType { get; set; }

        /// <summary>
        /// XML存储节点类型，是只有一个值还是一个数据列表
        /// </summary>
        public NodeType NodeType { get; set; }

        /// <summary>
        /// 值内容
        /// </summary>
        public object Value { get; set; }

        public ConfigValue()
        {
            Name = "";
            Value = "";
            DataType = typeof(string);
            NodeType = NodeType.Single;
        }
        public ConfigValue(string name)
        {
            Name = name;
            Value = "";
            DataType = typeof(string);
            NodeType = NodeType.Single;
        }
        public ConfigValue(string name,object value)
        {
            Name = name;
            Value = value;
            DataType = typeof(string);
            NodeType = NodeType.Single;
        }
        /// <param name="name">名称</param>
        /// <param name="value">值</param>
        /// <param name="datatype">数据类型，请使用typeof()方法获取，如typeof(int)</param>
        public ConfigValue(string name,object value,Type datatype)
        {
            Name = name;
            Value = value;
            DataType = datatype;
            NodeType = NodeType.Single;
        }
        public ConfigValue(string name, object value, Type datatype, NodeType nodetype)
        {
            Name = name;
            Value = value;
            DataType = datatype;
            NodeType = nodetype;
        }
    }

    [Serializable]
    public enum NodeType
    {
        Single,
        Array
    }
}
